package until

import (
	"github.com/gin-gonic/gin"

	"net/http"
)

/*
code  表示成功 其他失败
msg:失败原因
data:具体数据
*/

type ResponseData struct{
	Code  int         `json:"code"`
	Msg   string      `json:"msg"`
	Data  interface{} `json:"data"`
}



func ResponseError(ctx *gin.Context,code int){
     responseData :=&ResponseData{
     	Code:code,
     	Msg:GetMsg(code),
	 }
	 ctx.JSON(http.StatusOK,responseData)
}

func ResponseSuccess(ctx *gin.Context,data interface{}){
	responseData :=&ResponseData{
		Code:ErrCodeSuccess,
		Msg:GetMsg(ErrCodeSuccess),
		Data:data,
	}
	ctx.JSON(http.StatusOK,responseData)
}
